package org.caijin.springrabbitMQ.mq;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Delivery;

import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.rabbit.listener.RabbitListenerContainerFactory;
import org.springframework.messaging.handler.annotation.Payload;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestBody;

@Component
@RabbitListener(queues = "TestQueue")
public class TestQueue {
    @RabbitHandler
    public void process(String msg, Channel channel,Message message) throws Exception {
        System.out.println("[TestQueue] received message: " + msg);
        /** 参数1：消息投递序号
         * 参数2：是否一次可以拒签多条消息
         * 参数3：拒签后消息是否重回队列
         * */
        channel.basicNack(message.getMessageProperties().getDeliveryTag(), false, false);

    }
}
